#pragma once

class tetrisMap
{
public:
        tetrisMap(int a_hposition);
        ~tetrisMap();
		void drawProjected(int eye[4], int eye2[4]);
		bool checkDown(int eye[4], int eye2[4]);
        //display the map
        void displayMap();
		void displayNextMap();
        //randomly generate a piece (TODO TELL IT WHAT TO MAKE)
        void createPiece();
        //set the next piece into an array
        void setNextPiece(int);
        //shift the pieces down
        void downShift();
		void slamPiece();
        //shift the pieces left
        void leftShift();
        //shift the pieces right
        void rightShift();
        //clear the map
        void clearMap();
        //add a piece to the static grid if it has collided
        void addToStatic();
        //check to see if there is a complete line after add to static
        void lineCheck();
        //flip the shape
        void flipShape();
        //check to see if the player lost the game returns true if they did
        bool checkLoss();
        //clear the static grid, resets the game
        void clearStatic();
        //Get the current difficulty value ~Garth
        int getDifficulty() {return m_difficultyLevel;}

		/** Neal's Functions for better encapsulation */

		//Shape rotatating helper functions
		void rotateLineToHorizontalPosition();
		void rotateLineToVerticalPosition();
		void rotateTshapeFirstClockwisePosition();
		void rotateTshapeSecondClockwisePosition();
		void rotateTshapeThirdClockwisePosition();
		void rotateTshapeFourthClockwisePosition();
		void rotateRightLShapeClockwiseFirstPosition();
		void rotateRightLShapeClockwiseSecondPosition();
		void rotateRightLShapeClockwiseThirdPosition();
		void rotateRightLShapeClockwiseFourthPosition();
		void rotateLeftLShapeClockwiseFirstPosition();
		void rotateLeftLShapeClockwiseSecondPosition();
		void rotateLeftLShapeClockwiseThirdPosition();
		void rotateLeftLShapeClockwiseFourthPosition();
		void rotateSShapeToHorizontalPosition();
		void rotateSShapeToVerticalPosition();
		void rotateZShapeToHorizontalPosition();
		void rotateZShapeToVerticalPosition();

		//Shape creating helper functions
		void createSquare();
		void createStraightLine();
		void createTShape();
		void createRightLShape();
		void createLeftLShape();
		void createSShape();
		void createZShape();

		//Next piece setup helper functions
		void setNextSquarePiece();
		void setNextStraightLinePiece();
		void setNextTShapePiece();
		void setNextRightLShapePiece();
		void setNextLeftLShapePiece();
		void setNextSShapePiece();
		void setNextZShapePiece();

		bool notDone;
		int m_hposition;

private:
		int m_boxHeight;
		int m_boxWidth;
		bool hitBottom;
		bool firstTime;
		bool singleDown;
        //height of map
        int m_height;
        //width of map
        int m_width;
        //the id if the shape that is currently active
        int m_curShapeID;
        //the id of the next shape
        int m_nextShapeID;
        //the current position of the shape (straight, left, right, updside down)
        int m_curShapePos;
        //the array of stars
        bool ** m_mapArray;
        //array for next piece
        bool ** m_nextArray;
        //the array of pieces that have already hit the bottom
        bool ** m_staticArray;
        //the array that holds the current piece that is moving
        bool ** m_pieceArray;
		//the color array
		int ** m_colorArray;
        //The players current score     ~Garth
        int m_playerScore;
        //The current difficulty level for the player ~Garth
        int m_difficultyLevel;

};
